package com.IronLogistic.IronService;

import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.jws.WebService;

import com.IronLogistic.SqlServer.GestorJdbc;

@WebService(targetNamespace = "http://IronService.IronLogistic.com/", endpointInterface = "com.IronLogistic.IronService.GoogleServiceSEI", portName = "GoogleServicePort", serviceName = "GoogleServiceService")
public class GoogleService implements GoogleServiceSEI {

	public String devolverPosicion(int piIdvehiculo, Date pdfecha)
	{
		System.out.print(" devolver");
		return "posicion";
	}	

	public String devolverOrdenDeEntrega(String psDestinos)
	{
		System.out.print(" destinos");
		return "Destinos";
	}	
	
	
	public boolean grabarPosicion(int pidVehiculo, Date pdfecha, String psLatitud, String psLongitud )
	{
		GestorJdbc gestor = new GestorJdbc();
		try {
			gestor.conectar();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}
		String sQuery;
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
		String sFecha = formatter.format(pdfecha);


		
		sQuery = "insert into kls_Posicion_Vehiculo (id_vehiculo,fecha,latitud,longitud)";
		sQuery += " values  ("+pidVehiculo+",'"+sFecha+"',"+psLatitud+","+psLongitud+")"; 
		try {
			gestor.doInsert(sQuery);
			return true;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}	
	}	
	
	
	
}
